#导入模块
#from datetime import date
#from posixpath import join
#import re
#from types import resolve_bases
#from typing_extensions import ParamSpecArgs #蓝图模块
from flask import Blueprint,request
#from flask.helpers import total_seconds
#from flask.wrappers import JSONMixin
#from werkzeug import datastructures #导入request
#from db import db1  
from flask.json import jsonify
from utils.myfile import myfile
#import os
#import json


bp_coures = Blueprint("course",__name__)
import datetime
# @bp_coures.route('/recordM')
# def recordM():
#     #获取id
#     id = request.args.get('typeid')
#     if id== '0':
#         sql = 'select * from record'
#     else:
#         sql = 'select * from record where typeid=%d' %(int(id))
#     res = db1.findall(sql)
#     list = []
#     for i in res:
#         dict = {'id':i['id'],'stime':datetime.datetime.strftime(i['stime'],'%y-%m-%d'),'etime':datetime.datetime.strftime(i['etime'],'%y-%m-%d'),'money':float(i['money'])}
#         list.append(dict)
#     return jsonify({"code":200,'list':list})
    


# @bp_coures.route('/detailM')
# def detailM():
#     id = request.args.get('id')
#     sql = "select * from record where id = %d"%(int(id))
#     res = db1.find(sql)
#     record = {'id':res['id','stime':datetime.datetime.strftime(res['stime'],'%y-%m-%d'),'money':float(res['money'])]}
#     return jsonify({"code":200,'record':record})

# #获取分类接口
# @bp_coures.route('/orderMe')
# def orderMe():
#     sql = 'select * from ordes'
#     res = db1.findall(sql)
#     return jsonify({"code":200,'list':res})

# #获取订单接口       
# @bp_coures.route('/orderMs')
# def orderMs():
#     sql = 'select * from orders'
#     res = db1.findall(sql)
#     return jsonify({"code":200,'list':res})

# #获取分类接口
# @bp_coures.route('/orderM',methods=['GET','PUT'])
# def orderM():
#     if request.method == "PUT":
#         id = request.args.get('id')
#         sql = "select * from orders where id=%d"%(int(id))
#         res = db1.find(sql)
#         #判断状态原来为1改成2，原来为2改成1
#         status = 2
#         if int(res['status']) == 2:
#             status=1            
        
#         #执行更新操作
#         sql1 = "update orders set status=%d where id=%d"%(status,int(id))
#         db1.insert(sql1)
#         return jsonify({"code":200})

#     else:
#         #当前页
#         page = int(request.args.get('page'))
#         #每页显示多少条
#         page_size = int(request.args.get('page_size'))
#         start = (page-1)*page_size
#         sql = 'select * from orders limit %d,%d'%(start,page_size)
#         res = db1.findall(sql)
#         #总条数
#         sql1 = "select count(id) from orders"
#         res1 = db1.find(sql1)
#         return jsonify({"code":200,'list':res,'total':res1['count(id)']})

#发红包200-0.01区间接口
@bp_coures.route('/sendmoney')
def sendmoney():
    money = request.args.get('money')
    #对数据进行有效性验证
    if not money:
        return jsonify({"code":10010,"mes":'请输入金额'})
    else:
        try:
             #格式验证
             money = float(money)
        except:
            return jsonify({'code':10012,'mes':'格式有误'})
    if money<200 and money>0.01:
        return jsonify({"code":200})
    else:
        return jsonify({"code":10012})   
#发红包200-0.01区间接口
# @bp_coures.route('/sendmoney')
# def sendmoney():
#     money = request.args.get('money')
#     #对数据进行有效性验证
#     if not money:
#         return jsonify({"code":10010,"mes":'请输入金额'})
#     else:
#         try:
#         #格式验证
#             money = float(money)
#         except:
#             return jsonify({'code':10012,'mes':'格式有误'})
#     if money<200 and money>0.01:
#             return jsonify({"code":200})
#     else:
#             return jsonify({"code":10012})
